﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Web;
using System.Web.UI;
using System.IO;

namespace YXQ.Common.Web
{
    public class ViewManager<T> where T : UserControl
    {
        private AjaxPageBase m_pageHolder;

        public T LoadViewControl(string path)
        {
            this.m_pageHolder = new AjaxPageBase();

            return (T)this.m_pageHolder.LoadControl(path);
        }

        public string RenderView(T control)
        {
            StringWriter output = new StringWriter();
            this.m_pageHolder.Controls.Add(control);
            HttpContext.Current.Server.Execute(this.m_pageHolder, output, true);
            return output.ToString();
        }
    }
}